package util

// 请求状态码
const (
	RECODE_OK      = 200 //请求成功 正常
	RECODE_FAIL    = 0   //失败
	RECODE_UNLOGIN = -1  //未登录 没有权限
)

// 业务逻辑状态码
const (
	RESPMSG_OK   = "1"
	RESPMSG_FAIL = "0"
	//用户
	RESPMSG_ERROR_USERLIST = "ERROR_USERS"
	RESPMSG_ERROR_USERINFO = "ERROR_USERINFO"

	//未登陆
	EEROR_UNLOGIN = "ERROR_UNLOGIN"

	RECODE_UNKNOWERR = "8000"
)

// 业务逻辑状态信息描述
var recodeText = map[string]string{
	RESPMSG_OK:    "成功",
	RESPMSG_FAIL:  "失败",
	EEROR_UNLOGIN: "未登陆无操作权限，请先登陆", //未登陆 没有权限
	//用户
	RESPMSG_ERROR_USERLIST: "查询用户失败",
	RESPMSG_ERROR_USERINFO: "查询用户信息失败",
	//其他错误
	RECODE_UNKNOWERR: "服务器未知错误",
}

func Recode2Text(code string) string {
	str, ok := recodeText[code]
	if ok {
		return str
	}
	return recodeText[RECODE_UNKNOWERR]
}
